package com.hotec.PROJECT_NAME.modules.sys.entity;

import com.gemcap.framework.data.entity.TreeAble;
import com.hotec.PROJECT_NAME.component.basic.AttachmentAble;
import com.hotec.PROJECT_NAME.component.basic.BaseEntity;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Size;
import java.util.List;


/**
 * 系统字典表
 *
 * @author llb
 */
@Data
@Table(name = "sys_dict")
@Accessors(chain = true)
public class SysDict extends BaseEntity implements Comparable<SysDict>, TreeAble<SysDict>, AttachmentAble<SysDict> {

    @Size(max = 100)
    @Column(name = "parent_id")
    private String parentId;

    @Size(max = 1000)
    @Column(name = "parent_path")
    private String parentPath;

    @Size(max = 100)
    @Column(name = "name")
    private String name;

    @Transient
    private List<SysAttachment> sysAttachments;

    @Size(max = 100)
    @Column(name = "code")
    private String code;

    /**
     * 备注
     */
    @Size(max = 100)
    @Column(name = "remark")
    private String remark;

    @Transient
    String label;
    @Transient
    String value;
    @Transient
    private List<SysDict> children = null;

    @Transient
    private Boolean disable;

    @Override
    public int compareTo(SysDict other) {
        if (other == null || other.getSort() == null || this.getSort() == null) {
            return -1;
        }

        return this.getSort().compareTo(other.getSort());
    }
}
